exports.refreshUserInformation = function (req, res) {

    //获取参数信息
    var bodyParams = req.routeInfo.bodyParams;

    //返回结果
    var resultData = {};

    //存储用户主键id
    var u_id = ""

    //存储命名空间id
    var n_id = ""

    //存储用户token
    var token = ""

    //任务流创建
    async.waterfall([

        //查询命名空间
        //检查用户是否存在
        //进行数据库的更新
        //查询token
        //全局变量socketUser的更新
        (cb)=> {

            db.field('n_id').where({
                "n_appid" : bodyParams.severAppId
            }).select("socket_namespace",(rs) => {

                if(rs.length == 0){
                    return RES.errorResponse(res,"此appId不存在");
                }
                n_id = rs[0].n_id
                cb();
            })

        },

        (cb)=> {

            db.field('u_id').where({
                "u_username"  : bodyParams.userId,
                "u_nid"       : n_id,
                "u_is_delete" : 0
            }).select("socket_user",(rs) => {

                if(rs.length == 0){
                    return RES.errorResponse(res,"用户不存在，请先获取token");
                }
                u_id = rs[0].u_id
                cb();
            })
        },

        (cb) => {

            db.where({
                "u_username" : bodyParams.userId,
                "u_is_delete" : 0
            }).update({
                "u_nickname":bodyParams.name,
                "u_id"      :n_id,
                "u_header":bodyParams.portraitUri ? bodyParams.portraitUri : ''
            },"socket_user",(rs)=>{
                cb()
            })

        },

        (cb) => {

            db.field('ut_token').where({
                "ut_uid" : u_id,
                "ut_is_delete" : 0
            }).select("socket_user_token",(rs)=>{
                token = rs[0].ut_token
                cb()
            })

        },

        (cb) => {
            socketObj._refreshUserInformation(bodyParams,(isTrue) => {
                if(!isTrue){
                    return RES.errorResponse(res,"刷新失败，请重试");
                }
                cb()
            })
        }

    ],()=> {

        //返回最终拼接结果
        RES.successResponse(res, resultData);

    });
    
}